//
//  MainViewController.swift
//  weibo
//
//  Created by mac on 15/12/12.
//  Copyright © 2015年 rong. All rights reserved.
//

import UIKit

class MainViewController: UITabBarController {
  //必选属性
    let mainTabBar = MainTabBar()
    override func viewDidLoad() {
        super.viewDidLoad()
        //tabBar是只读属性  不能直接进行设置 可以使用KVC 在运行时间接赋值
        
        setValue(mainTabBar, forKey: "tabBar")
        //添加子视图控制器
        addChildViewControllers()
    }
    //private 表示只能在本类中进行访问
    private func addChildViewControllers() {
        addChildViewController(HomeViewController(), title: "首页", imageName: "tabbar_home")
        addChildViewController(MessageViewController(), title: "消息", imageName: "tabbar_message_center")
        addChildViewController(DiscoverViewController(), title: "发现", imageName: "tabbar_discover")
        addChildViewController(ProfileViewController(), title: "我", imageName: "tabbar_profile")
    
    }
    private func addChildViewController(vc: UIViewController,title:String,imageName:String) {
        let nav = UINavigationController(rootViewController: vc)
        vc.title = title
        vc.tabBarItem.image = UIImage(named: imageName)
        addChildViewController(nav)
    }
}